<?php

/**
 * Created by ghostsf
 * Number: n006833
 * Date: 2016/4/20
 */

namespace app\admin\controller;

use think\Controller;
use app\admin\model\Grade;
use app\admin\model\Campus;
use app\admin\model\Classroom;
use app\admin\model\Teacher;
use app\admin\model\Classes;
use app\admin\model\Course;
use app\admin\model\Subject;
use app\admin\model\Schedule;
use app\admin\model\Student;
use think\Db;

/**
 * ajax 异步加载页面
 * Class Ajax
 * @package app\admin\controller
 */
class AjaxController extends CommonController {
    /**
     * 仪表盘
     */
    public function dashboard() {
        $team_id  = session('loginSession')['team_id'];

        $team = Db::table("up_team")->where('team_id',$team_id)->find();
        $this->assign('team',$team);
        return $this->fetch('course/manage');
    }

    /**
     * 团队信息管理
     */
    public function course_manage() {
        $team_id  = session('loginSession')['team_id'];
        $team = Db::table("up_team")->where('team_id',$team_id)->find();
        $this->assign('team',$team);
        return $this->fetch('course/manage');
    }
    /**
     * 团队公告
     */
    public function class_manage() {
//        $course = Db::table("up_team_adv")->alias('a')
//                    ->join('up_u_user u','a.user_id=u.user_id','left')
//                    ->field('a.*,u.user_username')
//                    ->select();
//        $this->assign('course',$course);
        return $this->fetch('course/manageadv');
    }
    /**
     * 团队任务
     * @return mixed
     */
    public function course_arrange() {
        return $this->fetch('course/release');
    }



    /**
     * @return mixed
     * 成员管理
     */
    public function project(){
        return $this->fetch('member/manage');

    }

    /**
     * 生活管理
     */
    public function student(){
        $where['region_fid'] = 'ZDvaTNytyem97oNtRh692WpwYW8C3YPr';
        $res = Db::table('up_dic_region')->where($where)->select();
        $this->assign('res',$res);
        return $this->fetch('life/manage');
    }
    /**
     * 学习管理 - 课程管理-发布课程
     * @return mixed
     */
    public function subject_manage() {
        return $this->fetch('study/manage');
    }

    /***
     * 学习管理 - 课程管理-发布目录
     */
    public function lunbo_manage(){
        $project_id = $_GET['project_id'];
        $this->assign('project_id',$project_id);
        $project_release_user_id = Db::table('up_project')->where('project_id',$project_id)->value('project_release_user_id');
        $uid = session('loginSession')['user_id'];
        if($project_release_user_id==$uid){
            $this->assign('project_user_status',1);
        }else{
            $this->assign('project_user_status',2);
        }
        return $this->fetch('study/catalog');

    }

    /***
     * 学习管理-课程管理-发布目录视频
     */
    public function advert_manage(){
        $uid = session('loginSession')['user_id'];

        $video_id = $_GET['video_id'];
        $this->assign('video_id',$video_id);
        $catalog_project_id = Db::table('up_project_catalog')->where('catalog_id',$video_id)->value('catalog_project_id');
        if($catalog_project_id!=''){
            $project_release_user_id = Db::table('up_project')->where('project_id',$catalog_project_id)->value('project_release_user_id');
            if($project_release_user_id==$uid){
                $this->assign('project_user_status',1);
            }else{
                $this->assign('project_user_status',2);
            }
        }
        return $this->fetch('study/video');
    }



    /**
     * 学习管理-书籍管理 -
     */

    public function goodat_manage(){
        return $this->fetch('book/manage');
    }

    /**
     * 学习管理 - 书籍目录
     */
    public function personal_settings(){
        $book_id = $_GET['book_id'];
        $this->assign('book_id',$book_id);
        $uid = session('loginSession')['user_id'];
        $book_send_publisher_id = Db::table('up_book')->where('book_id',$book_id)->value('book_send_publisher_id');
        if($book_send_publisher_id==$uid){
            $this->assign('project_user_status',1);
        }else{
            $this->assign('project_user_status',2);
        }
        return $this->fetch('book/catalog');
    }

    /**
     * 学习管理 - 培训管理
     */
    public function classtime_manage(){
        return $this->fetch('train/manage');
    }

    /**
     * 学习管理 - 题目管理
     */
    public function global_config(){
        $exam_id = $_GET['exam_id'];
        $this->assign('exam_id',$exam_id);
        return $this->fetch('subject/manage');

    }
    /**
     * 学习管理 -知识库管理
     */
    public function common_settings(){
        return $this->fetch('knowledge/manage');
    }
    /**
     * 菜单管理
     */
    public function menu_manage() {
        return $this->fetch('menu/manage');
    }

}
